package com.wfm.systemnotice.mapper;

import com.wfm.systemnotice.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author wfm
 * @since 2024-12-05
 */
public interface UserMapper extends BaseMapper<User> {

//    @Insert("<script>" +
//            "INSERT INTO user ( name, age, email) VALUES " +
//            "<foreach collection='list' item='item' separator=','>" +
//            "( #{item.name}, #{item.age}, #{item.email})" +
//            "</foreach> " +
//            "ON DUPLICATE KEY UPDATE " +
//            "age = VALUES(age), email = VALUES(email)" +
//            "</script>")
    int batchInsertOrUpdate( List<User> userList);

    @Select("<script>" +
            "SELECT id FROM user WHERE name IN " +
            "<foreach collection='names' item='name' open='(' separator=',' close=')'>" +
            "#{name}" +
            "</foreach>" +
            "</script>")
    List<Long> selectIdsByNames(@Param("names") List<String> names);
}
